<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>变量的解构赋值</title>
</head>
<body>
    <script>
        //ES6 
        //数组的解构赋值
        // let arr = ['小沈阳','刘能','赵四','宋小宝'];

        // // let xiao = arr[0];
        // // let liu = arr[1];
        // // let zhao = arr[2];
        // // let song = arr[3];
        // let [xiao, liu, zhao, song] = arr;
        // console.log(xiao, liu, zhao, song);

        //对象解构赋值 ***
        // let star = {
        //     name: '郑爽',
        //     age: 28,
        //     sing: function(){
        //         console.log('singing');
        //     },
        //     fabiao: function(){
        //         console.log('发飙');
        //     }
        // };

        // let name = star.name;
        // let age = star.age;
        // let sing = star.sing;

        // let {name, age, sing, fabiao} = star;
        // console.log(name, age, sing, fabiao);

        // let {sing, fabiao} = star;
        // console.log(sing, fabiao);

        //复杂数据的结构
        let eason = {
            name: '陈奕迅',
            age: '保密',
            songs: ['爱情转移','红玫瑰','浮夸','背包','十年']
        };

        let {name, age, songs: [ai, hong, fu, bei, shi]} = eason;

        console.log(ai, hong, fu, bei, shi);


    </script>
</body>
</html>